<?php
namespace Admin\Service;

/**
 * 退款功能后台服务
 */

class SectorService
{
    protected $m_res = array('rcode'=>0,'data'=>NULL,'msg'=>'500 Internal Error');

    //查询部门中的分公司
    public function getSubCompany( $_fields = 'sector_id,sector_name', $sector_id = FALSE )
    {
        $res = $this->m_res;
        if( !$_fields )
            $_fields = "*";
        $Mdo =  D('Admin/Sector');
        $wheres = array();
        $wheres['_string'] = '1=1';
        $wheres['is_subcompany'] = array('eq', 1);
        if( FALSE !== $sector_id )
                $wheres['sector_id'] = is_array( $sector_id ) ? array('in', $sector_id): array('eq', $sector_id );
        $data = $Mdo->field( $_fields )->where( $wheres )->select();
        if( $data ){
            $res['rcode'] = 1;
            $res['data'] = $data;
            $res['msg'] = 'OK';
        }
        else
            $res['msg'] = "查询数据为空";
        return $res;
    }
}

